﻿using System;
using Microsoft.Practices.Unity;

namespace MVVMtutorialAdvanced.VMLocator
{
	public class Indexer
	{
		public IUnityContainer UnityContainer { get; set; }

		private object GetViewModel(string viewModelTypeName)
		{
			var type = Type.GetType(viewModelTypeName);
			return UnityContainer.Resolve(type, viewModelTypeName);
		}

		public object this[string viewModel]
		{
			get { return GetViewModel(viewModel); }
		}
	}
}
